package com.mj.haier.calc.repository;

import com.mj.haier.calc.domain.ItfOutcomeStatmentBean;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;


/**
 * Spring Data  repository for the ItfOutcomeStatmentBean entity.
 */
@SuppressWarnings("unused")
@Repository
public interface ItfOutcomeStatmentBeanRepository extends JpaRepository<ItfOutcomeStatmentBean, Long> {
    Optional<ItfOutcomeStatmentBean> findByBillNo(String billNo);

    void deleteByBillNo(String billNo);

    @Query(nativeQuery = true,value = "select " +
        "t.id as id," +
        "t.settle_batch_id as bill_no," +
        "t.detail_count as detail_count," +
        "t.settle_amounts*100 as ap_amt," +
        "t.settle_Encourage_Amounts*100 as reward_amt," +
        "t.actual_amounts*100 as ac_amt," +
        "t.cars_team_code  as vendor_code," +
        "t.cars_team_name as vendor_name," +
        "t.trade_code as st_entity_code," +
        "t.add_1 as st_entity_name," +
        "'1' as bd_entity_code," +
        "'1'as bd_entity_name," +
        "'' as st_user_code," +
        "'' as st_user_name," +
        "t.fee_type_name as fee_type_name," +
        "t.fee_type_code as fee_type_code," +
        "t.jhi_account as account," +
        "SYSDATE() as created_time," +
        "SYSDATE() as gmt_create," +
        "'AzStatementCarsteam' as create_user," +
        "t.corporation as add1," +
        "t.cars_team_id as car_team_id," +
        "'黑瑞丽' as frnam," +
        "t.last_level as last_level," +
        "t.last_level as last_level," +
        "t.last_level_name as last_level_name," +
        "t.corporation as corporation," +
        "t.begin_date as bill_begin_date," +
        "t.end_date as bill_end_date," +
        "'KX' as origin_app," +
        "t.source_name_code as source_name_code," +
        "'r' as dock_status," +
        "'0' as status_flag," +
        "0 as reduce_amt," +
        "'AZF' as business_type," +
        "'0' as pay_type," +
        "t.source_name as source_name " +
        "from az_fin_settle_carsteam t " +
        "where t.fee_type_code = 'carsteam' " +
        "AND t.jhi_Account = ?1 " +
        "AND t.check_status = '0' " +
        "order by t.id " +
        " limit ?2")
    List<ItfOutcomeStatmentBean> findAllisNotCheckStatus(String jhiAccount, int size);

}
